---
title: "Canvassing Meta Analysis Replication Code"
author: "Jose S. Gomez"
date: "8/12/2023"
output: html_document
---


```{r, setup, include=FALSE}
rm(list=ls())       # clear objects in memory
knitr::opts_knit$set(root.dir = '/Users/gomez/Library/CloudStorage/Dropbox/GOTV V/Replication Files/Data') #Set Working Directory
```

#setup clean working environment, packages and data
```{r}
library(foreign) 
library(metafor) # meta-analysis package
library(stargazer)
library(meta)
gotv_canvass <- read.csv("GOTV V Canvass Data (Collapsed).csv")
```

#table A-2, Table A-2 replication, Meta-Analysis Results, by Base Rate of Turnout
```{r}
#Overall canvassing results
rma(yi = Meta_b, 
    sei= Meta_SE,
    method = "DL", 
    data= gotv_canvass)

#Overall canvassing Results by Turnout Rates
rma(yi = Meta_b[Control_turnout < 30], 
    sei= Meta_SE[Control_turnout < 30],
    method = "DL", 
    data= gotv_canvass)

rma(yi = Meta_b[Control_turnout >= 30 & Control_turnout <= 50], 
    sei= Meta_SE[Control_turnout >= 30 & Control_turnout <= 50],
    method = "DL", 
    data= gotv_canvass)

rma(yi = Meta_b[Control_turnout >= 50 & Control_turnout <= 70], 
    sei= Meta_SE[Control_turnout >= 50 & Control_turnout <= 70],
    method = "DL", 
    data= gotv_canvass)

rma(yi = Meta_b[Control_turnout >= 70], 
    sei= Meta_SE[Control_turnout >= 70],
    method = "DL", 
    data= gotv_canvass)

#nonadvocacy only w/ turnout rates
rma(yi = Meta_b[Control_turnout < 30 & Advocacy == 0], 
    sei= Meta_SE[Control_turnout < 30 & Advocacy == 0],
    method = "DL", 
    data= gotv_canvass)

rma(yi = Meta_b[Control_turnout >= 30 & Control_turnout <= 50 & Advocacy == 0], 
    sei= Meta_SE[Control_turnout >= 30 & Control_turnout <= 50 & Advocacy == 0],
    method = "DL", 
    data= gotv_canvass)

rma(yi = Meta_b[Control_turnout >= 50 & Control_turnout <= 70 & Advocacy == 0], 
    sei= Meta_SE[Control_turnout >= 50 & Control_turnout <= 70 & Advocacy == 0],
    method = "DL", 
    data= gotv_canvass)

rma(yi = Meta_b[Control_turnout >= 70 & Advocacy == 0], 
    sei= Meta_SE[Control_turnout >= 70 & Advocacy == 0],
    method = "DL", 
    data= gotv_canvass)
```


